package com.bstek.ureport.sample;

import com.bstek.ureport.Utils;
import com.bstek.ureport.definition.datasource.BuildinDatasource;
import com.bstek.ureport.provider.DataSourceProvider;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;

/**
 *  wenjp
 * 2023-05-29 11:25
 **/
@Component
public class BuildInDataSourceProvider implements DataSourceProvider {

    @Override
    public List<String> getDataSourceNames() {
        List<String> dataSources=new ArrayList<String>();
        for(BuildinDatasource datasource: Utils.getBuildinDatasources()){
            dataSources.add(datasource.name());
        }
        return dataSources;
    }

    @Override
    public Connection getConnection(String dataSourceName) {
        return Utils.getBuildinConnection(dataSourceName);
    }
}
